<?php	
/**
 * shipping_agent tester
 *
 * @package shipping_agent
 * @copyright Copyright 2009 Structured Solutions
 * @license http://www.codeplex.com/ShippingAgent/license Microsoft Public License (Ms-PL)
 * @version 3.6
 */

//  For debugging/testing purposes we need to turn ON error reporting. 
//  On default ZenCart installation errors turned OFF and any exception that happens on the page
//  gets silently discarded.

	error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
    //ini_set('display_errors', '1');
	ini_set("soap.wsdl_cache_enabled", "0");
    
	require("shippingagent_impl.php");
	
	$server = new SoapServer(dirname(__FILE__) . "/shippingagent.wsdl");
	$server->setClass("shippingagent_impl");

//	echo "=================\n";
//	echo "Supported Functions\n";
//	foreach ($server->getFunctions() as $function)
//		echo "    " . $function . "\n";

/*
 * GetFeatures Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetFeatures xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetNewAndUpdatedOrders Test
 *
 * PageKey has order id and last modified. For example,
 *
 *     <pageKey>1|2009-04-13 14:08:13</pageKey>
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetNewAndUpdatedOrders xmlns="http://www.codeplex.com/ShippingAgent">
            <orderStatusList>Delivered,Pending,Processing</orderStatusList>
            <paymentStatusList />
            <pageKey>1|2009-04-13 14:08:13</pageKey>
			<maxCount>1</maxCount>
		</GetNewAndUpdatedOrders>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetNewOrders Test
 *
 * PageKey only has order id. For example,
 *
 *     <pageKey>1</pageKey>
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetNewOrders xmlns="http://www.codeplex.com/ShippingAgent">
            <orderStatusList>Delivered,Pending,Processing</orderStatusList>
            <paymentStatusList />
            <pageKey>1</pageKey>
			<maxCount>1</maxCount>
		</GetNewOrders>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetOrder Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetOrder xmlns="http://www.codeplex.com/ShippingAgent">
			<orderId>1</orderId>
		</GetOrder>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetOrdersByRange Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetOrdersByRange xmlns="http://www.codeplex.com/ShippingAgent">
            <startOrderNumber />
            <endOrderNumber />
            <orderStatusList>1,2,3</orderStatusList>
            <paymentStatusList />
			<maxCount>5</maxCount>
		</GetOrdersByRange>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetOrderStatuses Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetOrderStatuses xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetPackage Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetPackage xmlns="http://www.codeplex.com/ShippingAgent">
			<orderId>1</orderId>
		</GetPackage>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetPaymentStatuses Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetPaymentStatuses xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetRateProviders Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetRateProviders xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetTrackingProviders Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetTrackingProviders xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/

/*
 * GetVersion Test
 */
/*
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetVersion xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/
		
/*
 * UpdatePackage Test
 */
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
        <UpdatePackage xmlns="http://www.codeplex.com/ShippingAgent">
            <update>
                <Destination>
                    <AddressId>327ed2bdb76f008c4f88ddc36eca5980</AddressId>
                    <City>Portland</City>
                    <Company />
                    <Country>US</Country>
                    <FirstName>Andy</FirstName>
                    <LastName>Miller</LastName>
                    <Line1>15021 NW Wendy Ln</Line1>
                    <Line2 />
                    <PostalCode>97229</PostalCode>
                    <Region>OR</Region>
                    <Residential>false</Residential>
                </Destination>
                <OrderId>2</OrderId>
                <PackageId>2</PackageId>
				<ShipDate>2009-01-05T00:00:00</ShipDate>
				<ShippingCost>3.0000</ShippingCost>
				<TrackingNumbers>1234</TrackingNumbers>
            </update>
        </UpdatePackage>
	</soap:Body>
</soap:Envelope>
END;

		
/*		
$HTTP_RAW_DATA_POST = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<UpdatePackage xmlns="http://www.codeplex.com/ShippingAgent">
			<update>
				<Destination>
					<AddressId>d41d8cd98f00b204e9800998ecf8427e</AddressId>
					<FirstName />
					<LastName />
					<Residential>false</Residential>
				</Destination>
				<OrderId>1</OrderId>
				<PackageId>1</PackageId>
			</update>
		</UpdatePackage>
	</soap:Body>
</soap:Envelope>		
END;
*/

	//echo "=================\n";
	$server->handle($HTTP_RAW_POST_DATA);
	//echo "=================\nok\n";
	
?>